Skip to content

Conversation

@Baba05206
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Fixed the issues with the 'My Book Library' website issues as per the readme instructions.

Questions

@Baba05206 Baba05206 added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Flows The name of the module. labels Dec 15, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if any of this general feedback can help you further improve your code?
https://github.com/cjyuan/Module-Data-Flows/blob/book-library-feedback/debugging/book-library/feedback.md

Doing so can help me speed up the review process. Thanks.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Dec 16, 2025
@Baba05206
Copy link
Author

I have implemented the improvements. I did make a few mistakes in the process that i tried to reverse, but could not be sure i reversed all. But requested improvements were implemented.

@Baba05206 Baba05206 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 16, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you have is a rewritten and enhanced version of the original app!

Code looks good. Just have a few questions to check you understanding.

} else {
readStatus = "No";

if (!pagesRaw || !Number.isFinite(pages) || pages <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the checks is redundant.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out. I see that I was checking/converting the same value twice. I’ve removed the extra check to keep the code cleaner

const parsed = JSON.parse(raw);
if (!Array.isArray(parsed)) return false;
myLibrary = parsed.map(
(o) => new Book(o.title, o.author, Number(o.pages), !!o.check)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to explicitly type-cast o.pages and o.check?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback! I realized that since my Book class constructor already handles the type conversion (using Number() and Boolean()), explicitly casting them again inside the .map() function in loadStorage was unnecessary and repetitive. I'll clean that up to make the code more concise.

Comment on lines 107 to 110
function showConfirm(message) {
return new Promise((resolve) => {
confirmDescEl.textContent = message;
confirmModalEl.classList.remove("modal-hidden");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why implement this function to return a promise instead of true/false directly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used a Promise because I wanted the code to 'wait' for the user to click a button in my custom modal, similar to how an API call works. However, I realize now that since this is a simple UI interaction, using a Promise adds unnecessary complexity. I will simplify the logic by moving the 'Delete' action directly into the button's click event handler instead of wrapping the whole process in a Promise

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mainly checking your understanding and you explained it well why you needed to use Promise.
The code looks correct to me and you didn't need to revert it.

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 17, 2025
@Baba05206 Baba05206 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 19, 2025
@cjyuan
Copy link
Contributor

cjyuan commented Dec 19, 2025

Well done in this exercise! Excellent implementation.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Data-Flows The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants